<?php

//------------------------------------------------------------------
// File: events.code.php
// Author: Bryan Frost
// Date Created: 2010-03-25
//
// events.php codebehind
//------------------------------------------------------------------
	
require_once('dataAccess.php');
require_once('utility.php');
require_once('../classes/Player.class.php');
require_once('../classes/Event.class.php');
require_once('../classes/Team.class.php');

// Create HTML table rows for events
function GenerateEventTableRows()
{
	//$result = GetAllEvents();
	//$playerPreviewCollection = Player::GetAllPlayerPreviews();
	$eventsPreviewCollection = Event::GetAllEventPreviews();
	
	$i = 0;
	//while($row = mysqli_fetch_array($result))
	foreach($eventsPreviewCollection as $key => $value)
	{
		$event = new Event($row['EventID']);
		
		$eventId =			$eventsPreviewCollection[$key]->GetEventId();
		$tournamentId =		$eventsPreviewCollection[$key]->GetTournamentId();
		$tournamentDate =	$eventsPreviewCollection[$key]->GetTournamentDate();
		$divisionId =		$eventsPreviewCollection[$key]->GetDivisionId();
		$divisionName =		$eventsPreviewCollection[$key]->GetDivisionName();
		$genderId =			$eventsPreviewCollection[$key]->GetGenderId();
		$numberOfTeams =	$eventsPreviewCollection[$key]->GetNumberOfTeams();
		$eventFormat =		$eventsPreviewCollection[$key]->GetEventFormat();
		
		// Alternate rows have unique css class "alternate"
		$cssRow = ($i & 1 ? "alternate" : "");
		
		echo "<tr class=$cssRow>";
		echo "<td><a href=eventDetail.php?event=$eventId>$tournamentDate</a></td>";
		echo "<td>$eventFormat</td>";
		echo "<td>$numberOfTeams</td>";
		echo "</tr>";
		
		$i++;
	}
}
	
?>